package cn.bx.bid.service;

import cn.bx.bid.entity.Question;
import cn.bx.bid.repository.QuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;


@Service
@Transactional(readOnly = false)
public class QuestionService {
    @Autowired
    private QuestionRepository questionRepository;

    public List<Question> search() {
        return questionRepository.findAll();
    }

    public Question get(long id) {
        Optional<Question> findById = questionRepository.findById(id);
        return findById.get();
    }

    public int save(Question question) {
        questionRepository.save(question);
        return 1;
    }

    /*public int updateAnswerCount(long id) {
        return qd.updateAnswerCount(id);
    }

    public int addAnswer(Answer answer) {
        return qd.addAnswer(answer);
    }

    public List<Answer> getAnswer(long id) {
        return qd.getAnswer(id);
    }*/
}
